package com.limao.CacheManager;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.AsyncContext;
import javax.servlet.http.HttpServletResponse;

import com.limao.DBDataClass.CrowdPrestigeGoodsDataClass;
import com.limao.DBDataClass.CrowdPrestigeOrderDataClass;
import com.limao.DBDataClass.CrowdSysProjectClass;
import com.limao.DBDataClass.CrowdUserAuthClass;
import com.limao.DBProvider.CrowdPrestigeLogProvider;
import com.limao.DBProvider.CrowdPrestigeOrderProvider;
import com.limao.Model.LzPluginException;
import com.limao.Model.PublicData;
import com.limao.Model.RecvData;
import com.limao.Tool.CacheClass;


public class GoodsInfo {

	//&新鲜宝   取众筹项目列表信息
	public static Object resultSYSGoodsList(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		if (CacheClass.isEmpty(DataObj.cateid))
			DataObj.cateid = "0";
		if (CacheClass.isEmpty(DataObj.keyword))
			DataObj.keyword = "";
		if (CacheClass.isEmpty(DataObj.curpage))
			DataObj.curpage = "1";
		if (CacheClass.isEmpty(DataObj.priceid))
			DataObj.priceid = "0";
		
		PublicData goods = CrowdSysProjectCache.getInstance().getGoods_ListForCommon(CacheClass.getIntValue(DataObj.cateid),DataObj.keyword, CacheClass.getIntValue(DataObj.curpage),CacheClass.getIntValue(DataObj.priceid));
		if (goods == null) {
			throw new LzPluginException("数据库操作出错");
		}

		//生成result包给用户
		goods.state = "1";
		goods.m = m + "";
		goods.info = "获取众筹项目列表成功";
		
		return goods;
		
	}



	
	//&新鲜宝  取某众筹详细信息（项目主页）
	public static Object resultSYSGoodsINFO(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{

		// 参数检查(非空检查)
		if (CacheClass.isEmpty(DataObj.projectid)) {
			throw new LzPluginException("内容为空或者参数不正确");
		}
		// 参数检查（值范围、正确性检查）
		int projectid = CacheClass.getIntValue(DataObj.projectid);

		CrowdSysProjectClass goods = CrowdSysProjectCache.getInstance().load_Goods_Info_ById(projectid);

		if (goods == null) {
			throw new LzPluginException("数据库操作出错");
		}

		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "获取商品详细信息成功";
		data.obj = goods;
		
		return data;
		
	}
	
	//&新鲜宝  发布众筹话题  或回复 话题 
	public static Object resultSYSGoodsDISCUSSInsert(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{

		// 参数检查(非空检查)
		if (CacheClass.isEmpty(DataObj.projectid)  || CacheClass.isEmpty(DataObj.text) ) {
			throw new LzPluginException("内容为空或者参数不正确");
		}

		if(CacheClass.isEmpty(DataObj.replayid))
		{
			DataObj.replayid="0";
		}
		
		int userid = CacheClass.getIntValue(DataObj.userid);
		int projectid = CacheClass.getIntValue(DataObj.projectid);
		int replayid = CacheClass.getIntValue(DataObj.replayid);
		
		if (!CrowdSysProjectCache.getInstance().insertDiscuss_ByProjectid(userid,projectid,replayid,DataObj.text)) {
			throw new LzPluginException("数据库操作出错");
		}

		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "发布成功";

		
		return data;
		
	}
	
	
	
	//&新鲜宝  取某众筹详细信息（话题页）
	public static Object resultSYSGoodsDISCUSSINFO(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{

		// 参数检查(非空检查)
		if (CacheClass.isEmpty(DataObj.projectid)) {
			throw new LzPluginException("内容为空或者参数不正确");
		}
		if (CacheClass.isEmpty(DataObj.curpage))
			DataObj.curpage = "1";
		// 参数检查（值范围、正确性检查）
		int projectid = CacheClass.getIntValue(DataObj.projectid);

		PublicData data = CrowdSysProjectCache.getInstance().load_Goods_Discuss_ById(projectid,CacheClass.getIntValue(DataObj.curpage));

		if (data == null) {
			throw new LzPluginException("数据库操作出错");
		}

		// 生成result包给用户
		data.state = "1";
		data.m = m + "";
		data.info = "获取评论信息成功";

		
		return data;
		
	}
	
	
	//&新鲜宝  取某众筹详细信息（支持者）
	public static Object resultSYSGoodsBuy(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{

		// 参数检查(非空检查)
		if (CacheClass.isEmpty(DataObj.projectid)) {
			throw new LzPluginException("内容为空或者参数不正确");
		}
		if (CacheClass.isEmpty(DataObj.curpage))
			DataObj.curpage = "1";
		// 参数检查（值范围、正确性检查）
		int projectid = CacheClass.getIntValue(DataObj.projectid);

		PublicData data = CrowdSysProjectCache.getInstance().load_Goods_Buy_ById(projectid,CacheClass.getIntValue(DataObj.curpage));

		if (data == null) {
			throw new LzPluginException("数据库操作出错");
		}

		// 生成result包给用户
		data.state = "1";
		data.m = m + "";
		data.info = "获取众筹支持者成功";

		
		return data;
		
	}	
	
	
	
	//活跃　商城商品列表	
	public static Object GET_SHOP_OPERATION_PRESTIGE(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		
		List<CrowdPrestigeGoodsDataClass> list = CrowdPrestigeGoodsCache.getInstance().Load_PrestigeGoods_All(userid);
		
		List<Object> list2= new ArrayList<Object>();
		if(list!=null && list.size()>0)
			list2.addAll(list);
		
		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "活跃商品列表成功";
		data.list=list2;

		
		return data;
		
	}
	
	//活跃商城的商品详情	
	public static Object GET_SHOP_OPERATION_PRESTIGE_GOODS_DETAIL(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		if(CacheClass.isEmpty(DataObj.prestigeid))
		{
			throw new LzPluginException("参数不能为空");
		}
		if(CacheClass.isEmpty(DataObj.userid))
		{
			throw new LzPluginException("未登陆");
		}
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		int prestigeid=CacheClass.getIntValue(DataObj.prestigeid);
		
		CrowdPrestigeGoodsDataClass obj = CrowdPrestigeGoodsCache.getInstance().Load_PrestigeGoods_ById(userid,prestigeid);
		if(obj==null)
		{
			throw new LzPluginException("无此商品。");
		}
		
		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "商品详情成功";
		data.obj=obj;
		
		
		return data;
		
	}
	
	//活跃　获得活跃记录	
	public static Object GET_SHOP_OPERATION_PRESTIGE_LOG(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		if(CacheClass.isEmpty(DataObj.curpage))
		{
			DataObj.curpage="1";
		}
		
		PublicData data = CrowdPrestigeLogProvider.getInstance().Load_PRESTIGE_LOG(userid,0,CacheClass.getIntValue(DataObj.curpage));

		if (data == null) {
			throw new LzPluginException("数据库操作出错");
		}

		// 生成result包给用户
		data.state = "1";
		data.m = m + "";
		data.info = "获取活跃记录成功";

		
		return data;
		
	}
	
	
	//活跃　领取　活跃商城商品
	public static Object GET_SHOP_OPERATION_PRESTIGE_GOODS(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		if(CacheClass.isEmpty(DataObj.prestigeid))
		{
			throw new LzPluginException("参数不能为空");
		}
		
		//取得活跃商城商品
		CrowdPrestigeGoodsDataClass obj=CrowdPrestigeGoodsCache.getInstance().Load_PrestigeGoods_ById(CacheClass.getIntValue(DataObj.prestigeid));
		if(obj==null)
		{
			throw new LzPluginException("物品不存或已下架");
		}
		if((CacheClass.getIntValue(obj.limitenum)-CacheClass.getIntValue(obj.buynum))<1)
		{
			throw new LzPluginException("没有库存啦！");
		}
		//是否满足活跃值条件
		CrowdUserAuthClass auth=CrowdUserAuthCache.getInstance().getUser(userid);
		if(auth==null)
		{
			throw new LzPluginException("无此用户");
		}
		if(CacheClass.getLongValue(auth.prestigevalue)<CacheClass.getLongValue(obj.requirevalue))
		{
			throw new LzPluginException("您的活跃值不够！");
		}
		
		//是否已领取过了
		if(CrowdPrestigeOrderProvider.getInstance().isGet(userid, CacheClass.getIntValue(DataObj.prestigeid)))
		{
			throw new LzPluginException("物品已领取过了，不能再领取！");
		}
		
		//生成领取订单
		
		if( !CrowdPrestigeOrderProvider.getInstance().CreateGet(userid,CacheClass.getIntValue(DataObj.prestigeid),obj))
		{
			throw new LzPluginException("数据库操作出错");
		}

		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "领取活跃物品成功";

		
		return data;
		
	}
	
	
	//活跃商城的订单列表	
	public static Object GET_SHOP_OPERATION_PRESTIGE_ORDER(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		
		List<CrowdPrestigeOrderDataClass> list = CrowdPrestigeOrderProvider.getInstance().Load_PrestigeOrder_All(userid);
		
		List<Object> list2= new ArrayList<Object>();
		if(list!=null && list.size()>0)
			list2.addAll(list);
		
		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "发布成功";
		data.list=list2;
		
		return data;
		
	}	
	
	//活跃商城的订单详情	
	public static Object GET_SHOP_OPERATION_PRESTIGE_ORDER_DETAIL(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		
		if(CacheClass.isEmpty(DataObj.orderid))
		{
			throw new LzPluginException("参数不能为空");
		}
		CrowdPrestigeOrderDataClass tmp = CrowdPrestigeOrderProvider.getInstance().Load_PrestigeOrder_byOrderid(CacheClass.getLongValue(DataObj.orderid));
		if(tmp==null)
		{
			throw new LzPluginException("订单不存在");
		}
		
		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "取订单详情成功";
		data.obj=tmp;
		
		return data;
		
	}	
	
	//活跃商城的订单 　申请发货	
	public static Object GET_SHOP_OPERATION_PRESTIGE_ORDER10(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		if(CacheClass.isEmpty(DataObj.orderid) || CacheClass.isEmpty(DataObj.address))
		{
			throw new LzPluginException("参数不能为空");
		}
		
		CrowdPrestigeOrderDataClass tmp = CrowdPrestigeOrderProvider.getInstance().Load_PrestigeOrder_byOrderid(CacheClass.getLongValue(DataObj.orderid));
		if(tmp==null)
		{
			throw new LzPluginException("订单不存在");
		}
		if(CacheClass.getIntValue(tmp.state)==0)
		{
			throw new LzPluginException("活跃物品已申请发货");
		}
		else if(CacheClass.getIntValue(tmp.state)==1)
		{
			throw new LzPluginException("活跃物品已回购");
		}
		
		//申请发货
		if(!CrowdPrestigeOrderProvider.getInstance().updateOrderQuerySend(userid,CacheClass.getLongValue(DataObj.orderid),tmp,DataObj.address))
		{
			throw new LzPluginException("活跃物品　申请发货失败");
		}
		
	
		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "申请发货成功";
		
		return data;
	}	

	
	//活跃商城的订单　回购操作	
	public static Object GET_SHOP_OPERATION_PRESTIGE_ORDER11(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		if(CacheClass.isEmpty(DataObj.orderid))
		{
			throw new LzPluginException("参数不能为空");
		}
		
		
		CrowdPrestigeOrderDataClass tmp = CrowdPrestigeOrderProvider.getInstance().Load_PrestigeOrder_byOrderid(CacheClass.getLongValue(DataObj.orderid));
		if(tmp==null)
		{
			throw new LzPluginException("订单不存在");
		}
		if(CacheClass.getIntValue(tmp.iscanback)==0)
		{
			throw new LzPluginException("该活跃订单不充许回购！");
		}
		if(CacheClass.getIntValue(tmp.state)==0)
		{
			throw new LzPluginException("活跃物品已申请发货");
		}
		else if(CacheClass.getIntValue(tmp.state)==1)
		{
			throw new LzPluginException("活跃物品已回购");
		}
		
		//进行回购操作
		if(!CrowdPrestigeOrderProvider.getInstance().updateOrderCallBuy(userid,CacheClass.getLongValue(DataObj.orderid),tmp))
		{
			throw new LzPluginException("活跃物品回购失败");
		}
		
	
		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "回购成功";
		
		return data;
		
	}	
	
	
	//实物奖品的订单列表	
	public static Object GET_SHOP_OPERATION_REDBAG_ORDER(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		
		List<CrowdPrestigeOrderDataClass> list = CrowdPrestigeOrderProvider.getInstance().Load_RedbagOrder_All(userid);
		
		List<Object> list2= new ArrayList<Object>();
		if(list!=null && list.size()>0)
			list2.addAll(list);
		
		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "发布成功";
		data.list=list2;
		
		return data;
		
	}	
	
	//实物奖品订单详情	
	public static Object GET_SHOP_OPERATION_REDBAG_ORDER_DETAIL(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		
		if(CacheClass.isEmpty(DataObj.orderid))
		{
			throw new LzPluginException("参数不能为空");
		}
		CrowdPrestigeOrderDataClass tmp = CrowdPrestigeOrderProvider.getInstance().Load_PrestigeOrder_byOrderid(CacheClass.getLongValue(DataObj.orderid));
		if(tmp==null)
		{
			throw new LzPluginException("订单不存在");
		}
		
		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "取订单详情成功";
		data.obj=tmp;
		
		return data;
		
	}	
	
	//实物奖品订单 　申请发货	
	public static Object GET_SHOP_OPERATION_REDBAG_ORDER10(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		if(CacheClass.isEmpty(DataObj.orderid) || CacheClass.isEmpty(DataObj.address))
		{
			throw new LzPluginException("参数不能为空");
		}
		
		CrowdPrestigeOrderDataClass tmp = CrowdPrestigeOrderProvider.getInstance().Load_PrestigeOrder_byOrderid(CacheClass.getLongValue(DataObj.orderid));
		if(tmp==null)
		{
			throw new LzPluginException("订单不存在");
		}
		if(CacheClass.getIntValue(tmp.state)==0)
		{
			throw new LzPluginException("活跃物品已申请发货");
		}
		else if(CacheClass.getIntValue(tmp.state)==1)
		{
			throw new LzPluginException("活跃物品已回购");
		}
		
		//申请发货
		if(!CrowdPrestigeOrderProvider.getInstance().updateOrderQuerySend(userid,CacheClass.getLongValue(DataObj.orderid),tmp,DataObj.address))
		{
			throw new LzPluginException("活跃物品　申请发货失败");
		}
		
	
		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "申请发货成功";
		
		return data;
	}	

	
	//实物奖品订单　回购操作	
	public static Object GET_SHOP_OPERATION_REDBAG_ORDER11(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		if(CacheClass.isEmpty(DataObj.orderid))
		{
			throw new LzPluginException("参数不能为空");
		}
		
		
		CrowdPrestigeOrderDataClass tmp = CrowdPrestigeOrderProvider.getInstance().Load_PrestigeOrder_byOrderid(CacheClass.getLongValue(DataObj.orderid));
		if(tmp==null)
		{
			throw new LzPluginException("订单不存在");
		}
		if(CacheClass.getIntValue(tmp.iscanback)==0)
		{
			throw new LzPluginException("该订单不充许回购！");
		}
		if(CacheClass.getIntValue(tmp.state)==0)
		{
			throw new LzPluginException("物品已申请发货");
		}
		else if(CacheClass.getIntValue(tmp.state)==1)
		{
			throw new LzPluginException("物品已回购");
		}
		
		//进行回购操作
		if(!CrowdPrestigeOrderProvider.getInstance().updateOrderCallBuy(userid,CacheClass.getLongValue(DataObj.orderid),tmp,true))
		{
			throw new LzPluginException("物品回购失败");
		}
		
	
		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "回购成功";
		
		return data;
		
	}		
	
	
	
	//虚拟币商城商品列表	
	public static Object GET_SHOP_OPERATION_Vr_PRESTIGE(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		
		List<CrowdPrestigeGoodsDataClass> list = CrowdPrestigeGoodsCache.getInstance().Load_PrestigeGoods_Vr_All(userid);
		
		List<Object> list2= new ArrayList<Object>();
		if(list!=null && list.size()>0)
			list2.addAll(list);
		
		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "商品列表成功";
		data.list=list2;

		
		return data;
		
	}
	//虚拟币商城的商品详情		
	public static Object GET_SHOP_OPERATION_PRESTIGE_Vr_GOODS_DETAIL(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		if(CacheClass.isEmpty(DataObj.prestigeid))
		{
			throw new LzPluginException("参数不能为空");
		}
		if(CacheClass.isEmpty(DataObj.userid))
		{
			throw new LzPluginException("未登陆");
		}
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		int prestigeid=CacheClass.getIntValue(DataObj.prestigeid);
		
		
		CrowdPrestigeGoodsDataClass obj = CrowdPrestigeGoodsCache.getInstance().Load_PrestigeGoods_Vr_Id(userid,prestigeid);
		if(obj==null)
		{
			throw new LzPluginException("无此商品。");
		}
		
		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "商品详情成功";
		data.obj=obj;

		
		return data;
		
	}	
	
	//购买虚拟币商城商品
	public static Object GET_SHOP_OPERATION_PRESTIGE_Vr_GOODS(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		if(CacheClass.isEmpty(DataObj.prestigeid))
		{
			throw new LzPluginException("参数不能为空");
		}
		if(CacheClass.isEmpty(DataObj.num))
		{
			DataObj.num="1";
		}
		int num=CacheClass.getIntValue(DataObj.num);
		//取得虚拟币商城商品
		CrowdPrestigeGoodsDataClass obj=CrowdPrestigeGoodsCache.getInstance().Load_PrestigeVrGoods_ById(CacheClass.getIntValue(DataObj.prestigeid));
		if(obj==null)
		{
			throw new LzPluginException("物品不存或已下架");
		}
		if((CacheClass.getIntValue(obj.limitenum)-CacheClass.getIntValue(obj.buynum))<num)
		{
			throw new LzPluginException("没有库存啦！");
		}
		//虚拟币是否足够
		CrowdUserAuthClass auth=CrowdUserAuthCache.getInstance().getUser(userid);
		if(auth==null)
		{
			throw new LzPluginException("无此用户");
		}
		if(CacheClass.getDoubleValue(auth.virtualcoin)<num*CacheClass.getLongValue(obj.requirevalue))
		{
			throw new LzPluginException("您的狸猫豆值不够！");
		}
		
			
		//生成领取订单
		if( !CrowdPrestigeOrderProvider.getInstance().CreateVrGet(userid,CacheClass.getIntValue(DataObj.prestigeid),num,obj))
		{
			throw new LzPluginException("数据库操作出错");
		}

		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "购买成功物品成功";

		
		return data;
		
	}
	
	
	//虚拟币商城订单列表	
	public static Object GET_SHOP_OPERATION_PRESTIGE_Vr_ORDER(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		
		List<CrowdPrestigeOrderDataClass> list = CrowdPrestigeOrderProvider.getInstance().Load_PrestigeOrder_Vr_All(userid);
		
		List<Object> list2= new ArrayList<Object>();
		if(list!=null && list.size()>0)
			list2.addAll(list);
		
		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "取订单列表成功";
		data.list=list2;
		
		return data;
		
	}
	
	//虚拟币商城订单详情	
	public static Object GET_SHOP_OPERATION_PRESTIGE_Vr_ORDER_DETAIL(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		if(CacheClass.isEmpty(DataObj.orderid))
		{
			throw new LzPluginException("参数不能为空");
		}
		CrowdPrestigeOrderDataClass tmp = CrowdPrestigeOrderProvider.getInstance().Load_PrestigeOrder_byOrderid(CacheClass.getLongValue(DataObj.orderid));
		if(tmp==null)
		{
			throw new LzPluginException("订单不存在");
		}

		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "取订单列表详情";
		data.obj=tmp;
		
		return data;
		
	}	
	
	//虚拟币商城订单 　申请发货	
	public static Object GET_SHOP_OPERATION_PRESTIGE_Vr_ORDER10(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		if(CacheClass.isEmpty(DataObj.orderid) || CacheClass.isEmpty(DataObj.address))
		{
			throw new LzPluginException("参数不能为空");
		}
		
		CrowdPrestigeOrderDataClass tmp = CrowdPrestigeOrderProvider.getInstance().Load_PrestigeOrder_byOrderid(CacheClass.getLongValue(DataObj.orderid));
		if(tmp==null)
		{
			throw new LzPluginException("订单不存在");
		}
		if(CacheClass.getIntValue(tmp.state)==0)
		{
			throw new LzPluginException("物品已申请发货");
		}
		else if(CacheClass.getIntValue(tmp.state)==1)
		{
			throw new LzPluginException("物品已回购");
		}
		
		//申请发货
		if(!CrowdPrestigeOrderProvider.getInstance().updateOrderQuerySend(userid,CacheClass.getLongValue(DataObj.orderid),tmp,DataObj.address))
		{
			throw new LzPluginException("物品　申请发货失败");
		}
		
	
		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "申请发货成功";
		
		return data;
	}	

		
	//虚拟币商城订单　回购操作	
	public static Object GET_SHOP_OPERATION_PRESTIGE_Vr_ORDER11(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		if(CacheClass.isEmpty(DataObj.orderid))
		{
			throw new LzPluginException("参数不能为空");
		}
		
		
		CrowdPrestigeOrderDataClass tmp = CrowdPrestigeOrderProvider.getInstance().Load_PrestigeOrder_byOrderid(CacheClass.getLongValue(DataObj.orderid));
		if(tmp==null)
		{
			throw new LzPluginException("订单不存在");
		}
		if(CacheClass.getIntValue(tmp.iscanback)==0)
		{
			throw new LzPluginException("该商品订单不允许回购");
		}
		if(CacheClass.getIntValue(tmp.state)==0)
		{
			throw new LzPluginException("物品已申请发货");
		}
		else if(CacheClass.getIntValue(tmp.state)==1)
		{
			throw new LzPluginException("物品已回购");
		}
		
		//进行回购操作
		if(!CrowdPrestigeOrderProvider.getInstance().updateOrderVrCallBuy(userid,CacheClass.getLongValue(DataObj.orderid),tmp))
		{
			throw new LzPluginException("物品回购失败");
		}
		
	
		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "回购成功";
		
		return data;
		
	}	
		
	//取虚拟币变动记录	
	public static Object GET_SHOP_OPERATION_PRESTIGE_Vr_LOG(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{
		// 参数检查1(默认值赋值)
		int userid=CacheClass.getIntValue(DataObj.userid);
		if(CacheClass.isEmpty(DataObj.curpage))
		{
			DataObj.curpage="1";
		}
		
		PublicData data = CrowdPrestigeLogProvider.getInstance().Load_PRESTIGE_LOG(userid,1,CacheClass.getIntValue(DataObj.curpage));

		if (data == null) {
			throw new LzPluginException("数据库操作出错");
		}

		// 生成result包给用户
		data.state = "1";
		data.m = m + "";
		data.info = "获取活跃记录成功";

		
		return data;
		
	}
	
	
	//&新鲜宝  取支付方式
	public static Object resultSYSPayType(HttpServletResponse response,AsyncContext asyncContext,int m,RecvData DataObj) throws LzPluginException
	{

		if(CacheClass.isEmpty(DataObj.apptype)	)
		{
			throw new LzPluginException("内容为空或者参数不正确");
		}
		
		/*  apptype 0:网页   1:android  2:ios */
		int apptype = CacheClass.getIntValue(DataObj.apptype);
		int AliPa=0;
		int WxPay=0;
		int UnionPay=0;
		int BalancePay=0;
		
		int alipayType=CacheClass.getIntValue(BaseDataCacheManager.getInstance().Load_Param("alipayType").trim());
		
		BalancePay=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("balancePay").trim());
		int IapPay=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("iapPay").trim());
		switch(apptype)
		{
		case 0:
			AliPa=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("webAliPay").trim());
			WxPay=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("webWxPay").trim());
			UnionPay=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("webUnionPay").trim());
			break;
		case 1:
			AliPa=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("androidAliPay").trim());
			WxPay=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("androidWxPay").trim());
			UnionPay=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("androidUnionPay").trim());
			break;
		case 2:
			AliPa=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("iosAliPay").trim());
			WxPay=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("iosWxPay").trim());
			UnionPay=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("iosUnionPay").trim());
			break;
		default:
			AliPa=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("androidAliPay").trim());
			WxPay=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("androidWxPay").trim());
			UnionPay=CacheClass.getIntValue(CacheClass.getSYS_BaseDataCacheManager().Load_Param("androidUnionPay").trim());
			
		}
	
		// 生成result包给用户
		PublicData data = new PublicData();
		data.state = "1";
		data.m = m + "";
		data.info = "获取支付方式信息成功";
		data.AliPa=AliPa+"";
		data.WxPay=WxPay+"";
		data.UnionPay=UnionPay+"";
		data.BalancePay=BalancePay+"";
		data.IapPay=IapPay+"";
		data.AlipayType=alipayType+"";
		
		
		return data;
		
	}
	
}
